// Magic Software, Inc.
// http://www.magic-software.com
// Copyright (c) 2000, All Rights Reserved
//
// Source code from Magic Software is supplied under the terms of a license
// agreement and may not be copied or disclosed except in accordance with the
// terms of that agreement.  The various license agreements may be found at
// the Magic Software web site.  This file is subject to the license
//
// RESTRICTED USE SOURCE CODE
// http://www.magic-software.com/License/restricted.pdf

#ifndef MGCRENDERER_H
#define MGCRENDERER_H

#include "MgcCamera.h"
#include "MgcColor.h"
#include "MgcAlphaState.h"
#include "MgcDitherState.h"
#include "MgcFogState.h"
#include "MgcLightState.h"
#include "MgcMaterialState.h"
#include "MgcShadeState.h"
#include "MgcTextureState.h"
#include "MgcVertexColorState.h"
#include "MgcWireframeState.h"
#include "MgcZBufferState.h"
class MgcGPTriMesh;
class MgcNode;
class MgcParticles;
class MgcPolyline;
class MgcPolypoint;
class MgcTriMesh;


class MgcRenderer : public MgcObject
{
    MgcDeclareRTTI;

public:
    virtual ~MgcRenderer ();

    int GetWidth () const;
    int GetHeight () const;

    MgcCameraPtr SetCamera (MgcCamera* pkCamera);
    MgcCameraPtr GetCamera ();

    void SetState (const MgcRenderStatePtr aspkState[]);

    virtual void SetBackgroundColor (const MgcColor& rkColor);
    const MgcColor& GetBackgroundColor () const;
    virtual void ClearBackBuffer () = 0;
    virtual void DisplayBackBuffer () = 0;
    virtual void ClearZBuffer () = 0;
    virtual void ClearBuffers () = 0;

    void Draw (MgcNode* pkScene);
    virtual void Draw (const MgcParticles& rkParticle) { /**/ }
    virtual void Draw (const MgcPolyline& rkLine) { /**/ }
    virtual void Draw (const MgcPolypoint& rkPoint) { /**/ }
    virtual void Draw (const MgcTriMesh& rkMesh) { /**/ }
    virtual void Draw (const MgcGPTriMesh& rkMesh) { /**/ }
    virtual void Draw (int iX, int iY, const char* acText) { /**/ }

protected:
    // abstract base class
    MgcRenderer (int iWidth, int iHeight);
    MgcRenderer ();

    // state management
    virtual void InitializeState ();
    virtual void SetAlphaState (MgcAlphaState* pkState) = 0;
    virtual void SetDitherState (MgcDitherState* pkState) = 0;
    virtual void SetFogState (MgcFogState* pkState) = 0;
    virtual void SetLightState (MgcLightState* pkState) = 0;
    virtual void SetMaterialState (MgcMaterialState* pkState) = 0;
    virtual void SetShadeState (MgcShadeState* pkState) = 0;
    virtual void SetTextureState (MgcTextureState* pkState) = 0;
    virtual void SetVertexColorState (MgcVertexColorState* pkState) = 0;
    virtual void SetWireframeState (MgcWireframeState* pkState) = 0;
    virtual void SetZBufferState (MgcZBufferState* pkState) = 0;

    // window parameters
    int m_iWidth, m_iHeight, m_iQuantity;
    MgcColor m_kBackgroundColor;

    // camera for establishing view frustum
    MgcCameraPtr m_spkCamera;
};

MgcSmartPointer(MgcRenderer);
#include "MgcRenderer.inl"

#endif
